package com.itc.dispatch.controller;

import com.itc.common.core.domain.R;
import com.itc.common.core.validate.Add;
import com.itc.common.core.validate.Update;
import com.itc.dispatch.domain.AvoidFeign;
import com.itc.dispatch.domain.UserConfig;
import com.itc.dispatch.service.UserConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/config")
@Api(value = "userConfig", tags = "用户配置管理模块")
public class UserConfigController {

    @Autowired
    private UserConfigService userConfigService;



    @PostMapping("/add")
    @ApiOperation(value = "新增用户配置信息")
    public R add(@RequestBody @Validated(Add.class) UserConfig userConfig){
       return userConfigService.add(userConfig);
    }


    @GetMapping("/getMsg")
    @ApiOperation(value = "获取当前页面用户配置信息")
    public R getMsg(String path){
        return userConfigService.getMsg(path);
    }


    @PostMapping("/update")
    @ApiOperation(value = "修改用户配置信息")
    public R update(@RequestBody @Validated(Update.class) UserConfig userConfig){
        return userConfigService.change(userConfig);
    }


    @DeleteMapping("/delete")
    @ApiOperation(value = "删除当前用户配置信息")
    public R delete(String path){
        return userConfigService.delete(path);
    }



}
